package com.sxkiler.demo.netty;

import com.sxkiler.demo.netty.protocol.Protocl;
import com.sxkiler.demo.netty.protocol.ProtoclFactory;
import com.sxkiler.demo.netty.protocol.ProtoclType;
import com.sxkiler.demo.netty.register.*;
import com.sxkiler.demo.netty.service.HelloServiceImpl;
import com.sxkiler.demo.netty.service.IHelloService;

import java.net.MalformedURLException;
import java.net.URL;

public class Provider {
    public static void main(String[] args) throws MalformedURLException {
        URL url = new URL("localhost:8021");
        //远程服务注册地址
        RemoteRegister register = RemoteRegisterFactory.getRemoteRegister(RegisterType.ZOOKEEPER);
        register.register(IHelloService.class.getName(),url);

        //本地注册服务的实现类
        LocalRegister localRegister = LocalRegisterFactory.getLocalRegister(RegisterType.LOCAL);
        localRegister.register(IHelloService.class.getName(), HelloServiceImpl.class);
        //这里我又封装了一层协议层，我们都知道dubbo有基于netty的dubbo协议，有基于http的http协议，还有基于redis的redis协议等等。
        Protocl protocl = ProtoclFactory.getProtocl(ProtoclType.HTTP);
        protocl.start(url);
    }
}
